import request from '@/utils/request'

const api = {
  findAllRoleUrl: '/comdesk_role/find_all_role',
  addRoleUrl: '/comdesk_role/add_role',
  updateRoleUrl: '/comdesk_role/update_role',
  deleteRoleUrl: '/comdesk_role/delete_role',
  getUserRoleUrl: '/comdesk_role/get_user_role',
  changeRolePermUrl: '/comdesk_role/change_role_perm',
}

export async function findAllRoleApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.findAllRoleUrl,
    method: 'get',
    params: params,
  })
  return res
}

export async function addRoleApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.addRoleUrl,
    method: 'post',
    data: params,
  })
  return res
}

export async function updateRoleApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.updateRoleUrl,
    method: 'post',
    data: params,
  })
  return res
}

export async function deleteRoleApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.deleteRoleUrl,
    method: 'get',
    params: params,
  })
  return res
}

export async function getUserRoleApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.getUserRoleUrl,
    method: 'get',
    params: params,
  })
  return res
}

export async function changeRolePermApi(params: { [key: string]: string }) {
  const res = await request({
    url: api.changeRolePermUrl,
    method: 'post',
    data: params,
  })
  return res
}
